var express = require('express');
var path = require('path');
// var cookieParser = require('cookie-parser');
var logger = require('morgan');

const child_process = require('child_process');

//检查依赖
// child_process.exec('nc -help',function(err,out){
//     if(err)
//     throw err;

//     console.log(out.toString())
// })
const SPAWN = require('child_process').spawn;
const RL = require('readline');

var rl = RL.createInterface({
    input: SPAWN('git').on('error', function (error) {
        console.log('请安装git');
        process.exit();
    }).stdout,
    output: process.stdout,
    terminal: false
}).on('line', function (line) {
}).on('close', function () {
});

var config = require('config-lite')(__dirname);

var indexRouter = require('./routes/index');
var mavenRouter = require('./routes/maven');

var app = express();

console.log(config);
app.set('port', config.port);

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// app.use(cookieParser());
// app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/maven', mavenRouter);

module.exports = app;
